#!/bin/csh

# This job script should be copied and modified by Scaling.pl

#PBS -S /bin/csh
#PBS -N CRASH

# Use -q wide for 1024 or more cores.
#PBS -q normal

# To run on the 8-core Harpertown nodes (default now)
#PBS -l select=16:ncpus=8:model=har

# To run on the 8-core Nehalem nodes (2.4 times faster than Hapertown)
### PBS -l select=16:ncpus=8:model=neh

# To run on the 12-core Westmere nodes use this (2 times faster than Hapertown)
### PBS -l select=16:ncpus=12:model=wes
#PBS -l walltime=1:00:00
#PBS -j oe
#PBS -m e

# Specify group if necessary
### PBS -W group_list=...

# cd into the run directory
cd $PBS_O_WORKDIR

# run CRASH (the number of processors is already specified above)
# switch on BATL and set plot directory just before the run starts
perl -pi -e 's/^BATL/\#BATL/' PARAM.in
perl -pi -e 's/.*NamePlotDir/plot\t\tNamePlotDir/' PARAM.in
mpiexec CRASH.exe > runlog

# load opacity tables in next run(s)
perl -pi -e 's/^LOOKUPTABLE/\#LOOKUPTABLE/; s/save/load/' PARAM.in

# exit here unless we want to do more runs with modified PARAM.in
exit

# switch off BATL and use message_pass_cell
perl -pi -e 's/^\#BATL/BATL/' PARAM.in
perl -pi -e 's/^\#MESSAGEPASS/MESSAGEPASS/' PARAM.in
perl -pi -e 's/.*NamePlotDir/plot\t\tNamePlotDir/' PARAM.in
mpiexec CRASH.exe > runlog_bats_cell

# switch off BATL and use message_pass_dir
perl -pi -e 's/^\#BATL/BATL/' PARAM.in
perl -pi -e 's/^MESSAGEPASS/\#MESSAGEPASS/' PARAM.in
perl -pi -e 's/.*NamePlotDir/plot\t\tNamePlotDir/' PARAM.in
mpiexec CRASH.exe > runlog_bats_dir
